import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom'

function Index () {
  const [list, setList] = useState([{ id: 1, name: 'asdf' }, { id: 2, name: 'fda' }])
  const [num, setNum] = useState(0)

  useEffect(() => {
    console.log('useEffect, index')
    return () => {
      console.log('back, index, eff')
    }
  })

  return (<div>
    <div>num:{num}</div>
    <button onClick={() => { setNum(num + 1) }}>ann</button>
    {

      list.map(item => (
        <li key={item.id}>
          <Link to={'/list/' + item.id}>{item.name}</Link>
        </li>
      ))
    }</div>);
}

export default Index;